package com.example.d15_homework.homework03;

import java.util.Scanner;

/**
 * 主卡
 */
public class MasterCard {
    private String cardId; // 卡号
    private String name; // 户主
    private double balance; // 余额

    // 取款
    public void withdraw(double amount) {
        if (amount > balance) {
            // 说明取款的金额大于余额
            System.out.println("用主卡取" + amount + "元,取款失败,余额不足");
        } else {
            // 说明取款金额小于余额
            balance -= amount;
            System.out.println("用 主卡取" + amount + "元卡号为：" + cardId + "户主为," + name + ",取款成功,余额为：" + balance);
        }
    }

    // 存款
    public void deposit(double amount) {
        System.out.println("初始 银行卡 - 主卡 余额为：" + balance);
        if (amount <= 0) {
            System.out.println("存款失败,存款金额有误");
        }
        balance += amount;
        System.out.println("用 主卡存" + amount + "元卡号为：" + cardId + "户主为," + name + ",存款成功,余额为：" + balance);
    }

    public MasterCard() {
    }

    public MasterCard(String cardId, String name, double balance) {
        this.cardId = cardId;
        this.name = name;
        this.balance = balance;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}
